[ the cutting edge ]
G'Day Developers!
If you ask a new .NET developer (from the Access or VB6
world) what is the best thing about .NET Windows Forms, most
of your answers will be "Form Inheritance" that allows them
to keep a nice consistent look for all forms. If you ask
them a couple of months later, they will probably tell you
the worst thing about .NET Windows Forms is "Form
Inheritance". This is because they have had too many
problems with the bugs in the form designer regarding this
feature. Many abandon them altogether and jump on the user
control band wagon. Please don't, I have a solution to
this....
I think if you can keep the level of form inheritance to a
minimum, then you may not see the problem or at least you
will experience the problem less. Anyway even if you do,
stop whinging and just close down Visual Studio.NET and
restart. You don't change the base form that often anyway.
Well how do you keep it to a minimum? Well make the first
base form without any controls, only code (to make it as
flexible as possible and avoid having a multitude of base
forms).
We try to keep the number of controls on inherited forms,
and the levels of inheritance to a minimum, because it
reduces the risk of problems with the Visual Studio Designer
(you know when the controls start jumping around, or
disappearing from the Designer, or properties getting reset
on inherited copies or even the tab order getting
corrupted). Designer errors can also occur in the task list
if the InitializeComponent method fails.
Every form in your application should inherit from a base
form which has code common to every form.
See our examples.
Cheers until next time,
Adam
SSW Chief Architect and Microsoft Regional Director,
Australia
Got a comment for Adam?
6164616d636f67616e407373772e636f6d2e6175
|